'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 在线
 * @author sundbcn@gmail.com (sun debing)
 */

var pomelo = require('pomelo');
var _ = require('lodash');

/**
 * 在线状态查询, 回调: cb(err, online_status)
 */
exports.checkRoleOnline = function (role_id, cb) {
    if (!!pomelo.app) {
        var statusService = pomelo.app.get('statusService');
        statusService.getSidsByUid(role_id, function (err, list) {
            if (!!err) {
                return cb(null, false);
            }
            if (_.size(list) === 0) {
                return cb(null, false);
            }
            cb(null, true);
        });
    } else {
        cb(null, false);
    }
};
